﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GradeManager.classes
{
    public class Teacher : Person
    {
        public Teacher(string ID, string password)
        {
            this.ID = ID;
            this.password = password;
        }
        public bool addGrade(Score item)
        {
            for (int i = 0; i < MainPage.scoreList.Count; i++)
            {
                if (MainPage.scoreList[i].studentID == item.studentID
                    && MainPage.scoreList[i].courseID == item.courseID)
                {
                    return false;
                }
            }
            for (int i = 0; i < MainPage.allCourses.Count; i++)
            {
                if (item.courseID == MainPage.allCourses[i].ID && MainPage.allCourses[i].teacherID != ID)
                {
                    return false;
                }
            }
            MainPage.scoreList.Add(item);
            return true;
        }
        public bool updateGrade(Score item)
        {
            for (int i = 0; i < MainPage.scoreList.Count; i++)
            {
                if (MainPage.scoreList[i].studentID == item.studentID
                    || MainPage.scoreList[i].courseID == item.courseID)
                {
                    MainPage.scoreList[i].grade = item.grade;
                    return true;
                }
            }
            return false;
        }
    }
}
